package com.my.ads.lib.listen;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

import com.example.cleantest.JunkCleanActivity;
import com.example.cleantest.MemoryBoosterActivity;
import com.my.ads.lib.service.KeepService;

import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;

/**
 * Created by xuanyang on 2018/3/6.
 */

public class AppReceiver extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {

        //TODO 保活之后执行的操作
        context.startService(new Intent(context, KeepService.class));

        if (intent.getAction().equals("android.intent.action.PACKAGE_REMOVED")){
            Intent intent1 = new Intent(context, JunkCleanActivity.class);
            intent1.setFlags(FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent1);
        }else {
            Intent intent1 = new Intent(context, MemoryBoosterActivity.class);
            intent1.setFlags(FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent1);
        }
    }
}
